package com.hjm.ui.common;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hjm.ui.R;

public class Cell extends LinearLayout {
    private TextView cellTextView;
    public Cell(Context context) {
        super(context);
        init();
    }

    public Cell(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Cell);
        String text = a.getString(R.styleable.Cell_cellText);
        if (text != null) {
            cellTextView.setText(text);
        }
    }

    public Cell(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    private void init() {
        // 在这里添加你的布局和逻辑
        LayoutInflater.from(getContext()).inflate(R.layout.layout_cell, this, true);
        cellTextView = findViewById(R.id.text_view_cell_text);
    }

    public void setOnclickListener(OnClickListener listener) {
        ViewGroup viewGroup = findViewById(R.id.layout_cell);
        viewGroup.setOnClickListener(listener);
    }

    public void setText(String text) {
        cellTextView.setText(text);
    }
    public void setText(String text, int color, int size){
        cellTextView.setText(text);
        cellTextView.setTextColor(color);
        cellTextView.setTextSize(size);
    }
}
